package com.dadonas.fluxocaixa.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class GenericDAO extends SQLiteOpenHelper {
	
	protected SQLiteDatabase db;
	
	public void openConnection(){
		db = getWritableDatabase();
	}
	
	public void closeConnection(){
		close();
	}
	
	public GenericDAO(Context context) {
		super(context, DbConst.DB_NAME, null, DbConst.DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(DbConst.DB_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(DbConst.DB_UPGRADE);
		onCreate(db);
	}

}
